<template>
	<div>
		<city-header></city-header>
		<city-search :cities="cities"></city-search>
		<city-list :cities="cities"  :hot="hotCities" :letter="letter"></city-list>
		<city-alphabet :cities="cities" @change="handleletterClick"></city-alphabet>
	</div>
</template>

<script>
	import cityHeader from './components/header'
	import citySearch from './components/search'
	import cityList from './components/list'
	import cityAlphabet from './components/Alphabet'
	import axios from 'axios'
	export default {
		name: 'city',
		data() {
			return {
				cities:{},
				hotCities:[],
				letter:''
			};
		},
		components: {
			cityHeader,
			citySearch,
			cityList,
			cityAlphabet
		},
		methods: {
			getCityInfo() {
				axios.get('/static/mock/city.json').then(this.getCityInfoSucc)
			},
			getCityInfoSucc (res){
				console.log(res);
				res = res.data;
				if(res.ret && res.data){
					const data = res.data
					this.cities = data.cities;
					this.hotCities = data.hotCities
					console.log(data.cities)
				}
				
			},
			handleletterClick(letter){
				console.log(letter)
				this.letter = letter
			},
			handlrCityClick(city){
				console.log(city)
			}
		},
		mounted() {
			this.getCityInfo()
		}
	}
</script>

<style scoped lang="stylus">

</style>
